TARGET = doraemon 
TARGETDIR = ./
LIB += -lpcap -lpthread

C = gcc
CFLAGS += $(FLAG)

CXX = g++
CXXFLAGS += $(INCLUDE) $(FLAG)

CPPFLAGS += $(FLAG)

#下面四个命令通过模式匹配获取当前目录下的所有C,CPP,O文件
CPP_SOURCES = $(wildcard $(SRCDIR)*.cpp)
C_SOURCES = $(wildcard $(SRCDIR)*.c)
CPP_OBJS = $(patsubst $(SRCDIR)%.cpp, $(SRCDIR)%.o, $(CPP_SOURCES))
C_OBJS = $(patsubst $(SRCDIR)%.c, $(SRCDIR)%.o, $(C_SOURCES))

#下面把一些其他目录下的源文件也放到里面
SOURCES += $(CPP_SOURCES) $(C_SOURCES) $(OBJS:%.o=%.c*)
OBJS += $(CPP_OBJS) $(C_OBJS)

.PHONY: clean all cp cpp cpso

all: ..depend $(OUTDIR)$(TARGET) 

$(OUTDIR)$(TARGET): $(OBJS)
	$(CXX) -o $(OUTDIR)$(TARGET) $(OBJS) $(LIB)
# $(CXX) -L$(SHAREDLIB) -o $(OUTDIR)$(TARGET) $(OBJS) $(LIB)
#.SILENT: depend
..depend: ${SOURCES} $(OBJS)
	$(CXX) $(CPPFLAGS) $(INCLUDE) -E -MM ${SOURCES} > .depend
	-touch ..depend
	-chmod 777 ..depend .depend

-include .depend

clean:
	-rm -f $(OUTDIR)$(TARGET) $(OBJS) .depend

cleantarget:
	-rm -f $(OUTDIR)$(TARGET)

.print:$(SOURCES)
	-grep -H -n -i "fix.* bug\|tdbug" $? >> $(INSTALLROOT)/history.txt
	-touch .print
